using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMM.Core.Domain;
using ServiceStack.ServiceHost;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using MMM.Services.Base;
using MMM.Services.Operations;
using MMM.Services.Type;

namespace MMM.Services
{

    public class IdentificationService : BaseService<Identification>
    {
    }

    public class IdentificationGetSerice : BaseGetService<IdentificationPageGet, Identification>
    {
        protected override string CreateFilter(IdentificationPageGet request)
        {
            string sql = "";
            IList<Filter> lst = request.GetFilter();
            if (lst == null)
            {
                return string.Empty;
            }
            foreach (var item in lst)
            {
                if (string.IsNullOrEmpty(sql))
                {
                    if (item.Property == "EmpId")
                    {
                        item.Value = Guid.Parse(item.Value).ToString();
                        sql = item.ToSqlEque();
                    }
                    else
                    {
                        sql = item.ToSqlLike();
                    }
                }
                else
                {
                    if (item.Property == "EmpId")
                    {
                        item.Value = Guid.Parse(item.Value).ToString();
                        sql = string.Format("{0} and {1} ", sql, item.ToSqlEque());
                    }
                    else
                    {
                        sql = string.Format("{0} and {1}", sql, item.ToSqlLike());
                    }
                }
            }
            return sql;
        }
    }

    public class IdentificationDeleteService : BaseDeleteService<Identification, IdentificationDelete>
    {
    }
}
